﻿<navigation:PageView x:Class="Corina.Cydee.Apphub.Views.Users.UserView"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:be="clr-namespace:Corina.Interactivity.Silverlight;assembly=Corina.Interactivity.Silverlight"
                     xmlns:controls="clr-namespace:Corina.Controls.Silverlight;assembly=Corina.Controls.Silverlight"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                     xmlns:localViewmodel="clr-namespace:Corina.Cydee.Apphub.Viewmodels"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:navigation="clr-namespace:Corina.Cydee.Apphub.Base"
                     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                     xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                     Title="所有用户"
                     d:DesignHeight="480"
                     d:DesignWidth="800"
                     mc:Ignorable="d">
    <navigation:PageView.DataContext>
        <localViewmodel:UserViewmodel />
    </navigation:PageView.DataContext>
    <Grid x:Name="LayoutRoot">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <toolkit:BusyIndicator BusyContent="{StaticResource IDS_BUSYCONTENT_LOADING}" IsBusy="{Binding IsBusy}">
                <sdk:DataGrid AutoGenerateColumns="False"
                              CanUserSortColumns="False"
                              ColumnWidth="*"
                              IsReadOnly="True"
                              ItemsSource="{Binding ItemsCollection}"
                              ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn MinWidth="100"
                                                Binding="{Binding Account}"
                                                Header="帐号" />
                        <sdk:DataGridTextColumn MinWidth="100"
                                                Binding="{Binding Name}"
                                                Header="姓名" />
                        <sdk:DataGridTemplateColumn MinWidth="100" Header="级别">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                                        <HyperlinkButton Content="{Binding UserLevel}">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <i:InvokeCommandAction Command="{Binding Path=DataContext.ChangeCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding Id}" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </HyperlinkButton>
                                    </StackPanel>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTextColumn MinWidth="100"
                                                Binding="{Binding Kind}"
                                                Header="帐户类型" />
                        <sdk:DataGridTextColumn MinWidth="100"
                                                Binding="{Binding Industry}"
                                                Header="行业" />
                        <sdk:DataGridTextColumn MinWidth="100"
                                                Binding="{Binding RegisterTime,
                                                                  StringFormat=\{0:yyyy-MM-dd HH:mm:ss tt\}}"
                                                Header="注册时间" />

                        <sdk:DataGridTextColumn MinWidth="100"
                                                Binding="{Binding AccountStatus,
                                                                  Converter={StaticResource EnumTranslationConverter},
                                                                  ConverterParameter=ACCOUNTSTATUS}"
                                                Header="状态" />
                        <sdk:DataGridTemplateColumn MinWidth="100" Header="操作">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                                        <HyperlinkButton Content="锁定" Visibility="{Binding AccountStatus, Converter={StaticResource EuqalsToVisibilityConverter}, ConverterParameter=Normal}">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <i:InvokeCommandAction Command="{Binding Path=DataContext.BlockCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding Id}" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </HyperlinkButton>
                                        <HyperlinkButton Content="解锁" Visibility="{Binding AccountStatus, Converter={StaticResource EuqalsToVisibilityConverter}, ConverterParameter=Block}">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <i:InvokeCommandAction Command="{Binding Path=DataContext.UnblockCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding Id}" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </HyperlinkButton>
                                        <HyperlinkButton Margin="12,0" Content="删除">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <i:InvokeCommandAction Command="{Binding Path=DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=navigation:PageView}}" CommandParameter="{Binding Id}" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </HyperlinkButton>
                                    </StackPanel>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
            </toolkit:BusyIndicator>

            <Grid Grid.Row="1" Margin="0,12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <TextBlock VerticalAlignment="Center" Text="关键字：" />
                <TextBox Grid.Column="1" Text="{Binding Keywords, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Triggers>
                        <be:TextBoxEnterKeyTrigger>
                            <be:ExecuteCommandAction Command="{Binding LoadCommand}" />
                        </be:TextBoxEnterKeyTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
                <StackPanel Grid.Column="3" Orientation="Horizontal">
                    <Button Command="{Binding FirstPageCommand}" Style="{StaticResource FirstPageButtonStyle}" />
                    <Button Margin="12,0"
                            Command="{Binding PreviousPageCommand}"
                            Style="{StaticResource PreviousPageButtonStyle}" />
                    <TextBlock Margin="12,0" VerticalAlignment="Center">
                        <Run Text="{Binding Index}" />
                        <Run Text="/" />
                        <Run Text="{Binding PagesCount}" />
                    </TextBlock>
                    <Button Margin="12,0"
                            Command="{Binding NextPageCommand}"
                            Style="{StaticResource NextPageButtonStyle}" />
                    <Button Command="{Binding LastPageCommand}" Style="{StaticResource LastPageButtonStyle}" />
                </StackPanel>
            </Grid>
        </Grid>
        <controls:PromptDialog Title="账户信息"
                               HorizontalContentAlignment="Stretch"
                               VerticalContentAlignment="Stretch"
                               CloseCommand="{Binding CancelCommand}"
                               Visibility="{Binding ShowUpdate,
                                                    Converter={StaticResource BooleanToVisibilityConverter}}"
                               WindowHeight="400"
                               WindowWidth="400">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <StackPanel>

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="帐号：" />
                        <TextBlock Grid.Column="1"
                                   Style="{StaticResource ContentTextStyle}"
                                   Text="{Binding UpdateEntity.Account}" />
                    </Grid>

                    <Grid Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="名称：" />
                        <TextBlock Grid.Column="1"
                                   Style="{StaticResource ContentTextStyle}"
                                   Text="{Binding UpdateEntity.Name}" />
                    </Grid>

                    <Grid Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="电话：" />
                        <TextBlock Grid.Column="1"
                                   Style="{StaticResource ContentTextStyle}"
                                   Text="{Binding UpdateEntity.Mobile}" />
                    </Grid>

                    <Grid Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="电子邮件：" />
                        <TextBlock Grid.Column="1"
                                   Style="{StaticResource ContentTextStyle}"
                                   Text="{Binding UpdateEntity.Email}" />
                    </Grid>

                    <Grid Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="联系人：" />
                        <TextBlock Grid.Column="1"
                                   Style="{StaticResource ContentTextStyle}"
                                   Text="{Binding UpdateEntity.Linkman}" />
                    </Grid>

                    <Grid Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="注册时间：" />
                        <TextBlock Grid.Column="1"
                                   Style="{StaticResource ContentTextStyle}"
                                   Text="{Binding UpdateEntity.RegisterTime}" />
                    </Grid>

                    <Grid Margin="0,12,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock HorizontalAlignment="Right"
                                   VerticalAlignment="Center"
                                   Text="账户级别：" />
                        <ComboBox Grid.Column="1"
                                  ItemsSource="{Binding UserLevelCollection}"
                                  SelectedItem="{Binding SelectedUserLevel,
                                                         Mode=TwoWay}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Title}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </Grid>

                </StackPanel>

                <StackPanel Grid.Row="1"
                            HorizontalAlignment="Right"
                            Orientation="Horizontal">
                    <Button Width="60"
                            Margin="12,0"
                            Command="{Binding SubmitCommand}"
                            Content="提交" />
                    <Button Width="60"
                            Command="{Binding CancelCommand}"
                            Content="取消" />
                </StackPanel>
            </Grid>
        </controls:PromptDialog>
    </Grid>
</navigation:PageView>
